package cn.cheln.support.images;

import cn.cheln.support.unknown.ComparatorRepo;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Pattern;

public class MimeTypeMap
{
  private static MimeTypeMap sMimeTypeMap;
  private TreeMap<String, String> mExtensionToMimeTypeMap = new TreeMap(ComparatorRepo.stringKey);
  private HashMap<String, String> mMimeTypeToExtensionMap = new HashMap();

  public static Map<String, String> filterMapByKey(Map<String, String> paramMap, String paramString)
  {
    HashMap localHashMap = new HashMap();
    Iterator localIterator = paramMap.entrySet().iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        if (localHashMap.size() == 0)
          localHashMap = null;
        return localHashMap;
      }
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      if (!(((String)localEntry.getValue()).split("/")[0].contains(paramString)))
        continue;
      localHashMap.put((String)localEntry.getKey(), (String)localEntry.getValue());
    }
  }

  public static String getFileExtensionFromUrl(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0))
    {
      int i = paramString.lastIndexOf(63);
      if (i > 0)
        paramString = paramString.substring(0, i);
      int j = paramString.lastIndexOf(47);
      if (j >= 0);
      for (String str = paramString.substring(j + 1); (str.length() > 0) && (Pattern.matches("[a-zA-Z_0-9\\.\\-\\(\\)\\%]+", str)); str = paramString)
      {
        int k = str.lastIndexOf(46);
        if (k < 0)
          break;
        return str.substring(k + 1);
      }
    }
    return "";
  }

  public static MimeTypeMap getSingleton()
  {
    if (sMimeTypeMap == null)
    {
      sMimeTypeMap = new MimeTypeMap();
      sMimeTypeMap.loadEntry("application/vnd.shortcut.package-archive", "apk");
      sMimeTypeMap.loadEntry("application/rss+xml", "rss");
      sMimeTypeMap.loadEntry("application/vnd.oasis.opendocument.formula", "odf");
      sMimeTypeMap.loadEntry("application/vnd.oasis.opendocument.graphics", "odg");
      sMimeTypeMap.loadEntry("application/vnd.ms-excel", "xlt");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.spreadsheetml.template", "xltx");
      sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint", "pot");
      sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint", "pps");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.presentationml.template", "potx");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.presentationml.slideshow", "ppsx");
      sMimeTypeMap.loadEntry("application/vnd.visio", "vsd");
      sMimeTypeMap.loadEntry("application/x-apple-diskimage", "dmg");
      sMimeTypeMap.loadEntry("application/x-bittorrent", "torrent");
      sMimeTypeMap.loadEntry("application/x-debian-package", "deb");
      sMimeTypeMap.loadEntry("application/x-debian-package", "udeb");
      sMimeTypeMap.loadEntry("application/x-gtar", "tgz");
      sMimeTypeMap.loadEntry("application/x-gtar", "taz");
      sMimeTypeMap.loadEntry("application/x-shockwave-flash", "swf");
      sMimeTypeMap.loadEntry("application/x-tar", "tar");
      sMimeTypeMap.loadEntry("application/xhtml+xml", "xhtml");
      sMimeTypeMap.loadEntry("text/plain", "txt");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.wordprocessingml.document", "docx");
      sMimeTypeMap.loadEntry("application/msword", "doc");
      sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint", "ppt");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.presentationml.presentation", "pptx");
      sMimeTypeMap.loadEntry("application/vnd.ms-excel", "xls");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "xlsx");
      sMimeTypeMap.loadEntry("application/pdf", "pdf");
      sMimeTypeMap.loadEntry("application/rar", "rar");
      sMimeTypeMap.loadEntry("application/zip", "zip");
      sMimeTypeMap.loadEntry("audio/amr", "amr");
      sMimeTypeMap.loadEntry("audio/amr-wb", "awb");
      sMimeTypeMap.loadEntry("audio/midi", "mid");
      sMimeTypeMap.loadEntry("audio/midi", "midi");
      sMimeTypeMap.loadEntry("audio/mpeg", "mp3");
      sMimeTypeMap.loadEntry("audio/mp4", "m4a");
      sMimeTypeMap.loadEntry("audio/x-ms-wma", "wma");
      sMimeTypeMap.loadEntry("audio/x-pn-realaudio", "rm");
      sMimeTypeMap.loadEntry("audio/x-wav", "wav");
      sMimeTypeMap.loadEntry("audio/aac", "aac");
      sMimeTypeMap.loadEntry("audio/ogg", "ogg");
      sMimeTypeMap.loadEntry("audio/x-flac", "flac");
      sMimeTypeMap.loadEntry("image/bmp", "bmp");
      sMimeTypeMap.loadEntry("image/gif", "gif");
      sMimeTypeMap.loadEntry("image/jpeg", "jpeg");
      sMimeTypeMap.loadEntry("image/jpeg", "jpg");
      sMimeTypeMap.loadEntry("image/png", "png");
      sMimeTypeMap.loadEntry("image/tiff", "tiff");
      sMimeTypeMap.loadEntry("image/vnd.wap.wbmp", "wbmp");
      sMimeTypeMap.loadEntry("image/x-icon", "ico");
      sMimeTypeMap.loadEntry("image/webp", "webp");
      sMimeTypeMap.loadEntry("image/jps", "jps");
      sMimeTypeMap.loadEntry("image/mpo", "mpo");
      sMimeTypeMap.loadEntry("text/html", "htm");
      sMimeTypeMap.loadEntry("text/html", "html");
      sMimeTypeMap.loadEntry("text/lrc", "lrc");
      sMimeTypeMap.loadEntry("text/rtf", "rtf");
      sMimeTypeMap.loadEntry("text/text", "phps");
      sMimeTypeMap.loadEntry("text/xml", "xml");
      sMimeTypeMap.loadEntry("text/x-c++src", "cpp");
      sMimeTypeMap.loadEntry("text/x-chdr", "h");
      sMimeTypeMap.loadEntry("text/x-java", "java");
      sMimeTypeMap.loadEntry("video/3gpp", "3gpp");
      sMimeTypeMap.loadEntry("video/3gpp", "3gp");
      sMimeTypeMap.loadEntry("video/3gpp2", "3g2");
      sMimeTypeMap.loadEntry("video/3gpp2", "3gpp2");
      sMimeTypeMap.loadEntry("video/m4v", "m4v");
      sMimeTypeMap.loadEntry("video/mpeg", "mpeg");
      sMimeTypeMap.loadEntry("video/mpeg", "mpg");
      sMimeTypeMap.loadEntry("video/mp4", "mp4");
      sMimeTypeMap.loadEntry("video/x-ms-wmv", "wmv");
      sMimeTypeMap.loadEntry("video/x-msvideo", "avi");
      sMimeTypeMap.loadEntry("video/x-matroska", "mkv");
      sMimeTypeMap.loadEntry("video/x-matroska", "webm");
      sMimeTypeMap.loadEntry("video/mp2ts", "ts");
      sMimeTypeMap.loadEntry("video/x-ms-asf", "asf");
      sMimeTypeMap.loadEntry("video/flv", "flv");
      sMimeTypeMap.loadEntry("application/msword", "doc");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.wordprocessingml.template", "docx");
      sMimeTypeMap.loadEntry("application/vnd.ms-excel", "xls");
      sMimeTypeMap.loadEntry("application/vnd.openxmlformats-officedocument.spreadsheetml.template", "xlsx");
      sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint", "ppt");
      sMimeTypeMap.loadEntry("application/vnd.ms-powerpoint", "pptx");
      sMimeTypeMap.loadEntry("application/vnd.ms-wpl", "WPL");
      sMimeTypeMap.loadEntry("application/vcf", "vcf");
      sMimeTypeMap.loadEntry("lewa/theme", "lwt");
    }
    return sMimeTypeMap;
  }

  private void loadEntry(String paramString1, String paramString2)
  {
    if (!(this.mMimeTypeToExtensionMap.containsKey(paramString1)))
      this.mMimeTypeToExtensionMap.put(paramString1, paramString2);
    this.mExtensionToMimeTypeMap.put(paramString2, paramString1);
  }

  private static String mimeTypeFromExtension(String paramString)
  {
    return getSingleton().getMimeTypeFromExtension(paramString);
  }

  public String getExtensionFromMimeType(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0))
      return ((String)this.mMimeTypeToExtensionMap.get(paramString));
    return null;
  }

  public Map<String, String> getExtensionToMimeTypeMap()
  {
    return this.mExtensionToMimeTypeMap;
  }

  public Map<String, String> getExtensionToMimeTypeMap(String paramString)
  {
    if (paramString == null)
      return this.mExtensionToMimeTypeMap;
    return filterMapByKey(this.mExtensionToMimeTypeMap, paramString);
  }

  public String getMimeTypeFromExtension(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0))
      return ((String)this.mExtensionToMimeTypeMap.get(paramString));
    return null;
  }

  public boolean hasExtension(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0))
      return this.mExtensionToMimeTypeMap.containsKey(paramString);
    return false;
  }

  public boolean hasMimeType(String paramString)
  {
    if ((paramString != null) && (paramString.length() > 0))
      return this.mMimeTypeToExtensionMap.containsKey(paramString);
    return false;
  }
}

/* Location:           H:\360云盘\lewa_explorer_3.0\bin\FileApp_orig_dex2jar.jar
 * Qualified Name:     cn.cheln.support.images.MimeTypeMap
 * JD-Core Version:    0.5.2
 */